<template>
	<div class="page has-navbar has-tabbar" v-nav="{title: '销售商机', showBackButton: true}">
		<div class="page-content padding-top reserve-margin">
			<div class="car-editor">
				<div class="reserve">
					<ul>
						<li>
							<div class="car-editor-title">
								关注该车辆的用户
							</div>
							<list>
								<item v-for="item in car">
									<router-link :to="{path:'/customerQuery/'+carId+'/customerInfo/'+item.customerId,query:{customerId:item.customerId}}">
										<div class="car-editor-name">
											{{item.customerNickName}}
										</div>
										<div class="car-editor-input">
											{{item.createTime}}
										</div>
									</router-link>
								</item>
							</list>
						</li>
						<li>
							<div class="car-editor-title">
								关注同价位的用户推荐
							</div>
							<list>
								<item v-for="item in series">
									<router-link :to="{path:'/customerQuery/'+carId+'/customerInfo/'+item.customerId,query:{customerId:item.customerId}}">
										<div class="car-editor-name">
											{{item.customerNickName}}
										</div>
										<div class="car-editor-input">
											{{item.createTime}}
										</div>
									</router-link>
								</item>
							</list>
						</li>
						<li>
							<div class="car-editor-title">
								关注同车系的用户推荐
							</div>
							<list>
								<item v-for="item in much">
									<!-- {{item.customerShopId}} -->
									<router-link :to="{path:'/customerQuery/'+carId+'/customerInfo/'+item.customerId,query:{customerId:item.customerShopId}}">
										<div class="car-editor-name">
											{{item.customerNickName}}
										</div>
										<div class="car-editor-input">
											{{item.createTime}}
										</div>
									</router-link>
								</item>
							</list>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default{
		data(){
			return {
				car:[],
				series:[],
				much:[],
				carId:''
			}
		},
		computed:{
			params(){
				return this.$route.query.params
			}
		},
		methods:{
			getCustomerByCar(){
//				console.log(this.params.shopId)
				window.axios.get(baseUrl+'/crm-web/controller/customer/getCustomerByCar',{
					params:{
						carId:this.params.carId,
						marketId:this.params.marketId,
//						seriesId:this.params.seriesId,
						shopId:this.params.shopId
					}
				}).then((res)=>{
					this.car = JSON.parse(res.request.responseText).result
				})
			},
			getCustomerBySeries(){
				window.axios.get(baseUrl+'/crm-web/controller/customer/getCustomerByCar',{
					params:{
//						carId:this.params.carId,
						marketId:this.params.marketId,
						seriesId:this.params.seriesId,
						shopId:this.params.shopId
					}
				}).then((res)=>{
					this.series = JSON.parse(res.request.responseText).result
				})
			},
			getCustomerByCarMuch(){
				window.axios.get(baseUrl+'/crm-web/controller/customer/getCustomerSimilarPrice',{
					params:{
						carId:this.params.carId,
						marketId:this.params.marketId,
						carStockState:this.params.carStockState,
						shopId:this.params.shopId
					}
				}).then((res)=>{
					this.much = JSON.parse(res.request.responseText).result
				})
			}
		},
		created(){
			this.getCustomerByCar()
			this.getCustomerBySeries()
			this.getCustomerByCarMuch()
			// console.log(this.params.carId)
			if(!(this.params.carId))
				this.$router.push({path:'/home'})
		},
		mounted(){
			this.carId = this.params.carId
		}
	}
</script>
